import { KVAny } from "src/app/shared/type/kv";
import { State, Action, StateContext } from "@ngxs/store";

export namespace SettingActions {
  export class Greeting {
    static readonly type = "[SettingActions] Greeting";
    constructor(public person: string) {}
  }
}

export interface SettingStateModel {
  person: string;
}

@State<SettingStateModel>({
  name: "setting",
  defaults: {
    person: "World"
  }
})
export class SettingState {
  @Action(SettingActions.Greeting)
  greeting(
    ctx: StateContext<SettingStateModel>,
    action: SettingActions.Greeting
  ) {
    ctx.patchState({ person: action.person });
  }
}
